<?php


namespace App\HttpController;

use EasySwoole\Http\AbstractInterface\AbstractRouter;
use EasySwoole\Http\Request;
use EasySwoole\Http\Response;
use FastRoute\RouteCollector;

class Router extends AbstractRouter
{
    function initialize(RouteCollector $routeCollector)
    {
        /*
          * eg path : /router/index.html  ; /router/ ;  /router
         */
	$this->parseParams(AbstractRouter::PARSE_PARAMS_IN_GET);

//	$routeCollector->addRoute(['GET', 'POST'], '/router', '/adminapi/login/login');
	
	//login
	$routeCollector->get('/adminapi/captcha_pro', '/adminapi/login/captcha');
        $routeCollector->get('/adminapi/login/info','/adminapi/login/info');
        $routeCollector->post('/adminapi/login','/adminapi/login/login');
	
	
	
	//Common
        $routeCollector->get('/adminapi/menus','/adminapi/SystemMenus/menus');//获取左侧菜单
        $routeCollector->get('/adminapi/menusList','/adminapi/common/menusList');//获取搜索菜单列表
        $routeCollector->get('/adminapi/jnotice','/adminapi/common/jnotice');//消息提醒
        $routeCollector->get('/adminapi/logo','/adminapi/common/getLogo');//获取logo
        $routeCollector->get('/adminapi/home/order','/adminapi/common/orderChart');//首页订单图表
        $routeCollector->get('/adminapi/home/header','/adminapi/common/homeStatics');//首页统计数据
        $routeCollector->get('/adminapi/home/user','/adminapi/common/userChart');//首页用户图表
        $routeCollector->get('/adminapi/home/rank','/adminapi/common/purchaseRanking');//交易额排行
	
	//setting
        $routeCollector->put('/adminapi/setting/update_admin','/adminapi/setting/SystemAdmin/update_admin');//修改当前管理员信息
        $routeCollector->get('/adminapi/setting/admin/logout','/adminapi/setting/SystemAdmin/logout');//退出登陆
	//admin
        $routeCollector->get('/adminapi/setting/admin','/adminapi/setting/systemadmin/index');//管理员列表
        $routeCollector->get('/adminapi/setting/admin/create','/adminapi/setting/systemadmin/create');//管理员表单
        $routeCollector->get('/adminapi/setting/admin/{id}/edit','/adminapi/setting/systemadmin/edit');//编辑管理员表单
        $routeCollector->post('/adminapi/setting/admin','/adminapi/setting/systemadmin/save');//添加管理员
        $routeCollector->put('/adminapi/setting/admin/{id}','/adminapi/setting/systemadmin/update');//修改管理员
        $routeCollector->delete('/adminapi/setting/admin/{id}','/adminapi/setting/systemadmin/delete');//删除管理员
        $routeCollector->put('/adminapi/setting/set_status/{id}/{status}','/adminapi/setting/systemadmin/set_status');//显示管理员
	//menus
        $routeCollector->get('/adminapi/setting/menus','/adminapi/setting/systemmenus/index');//权限菜单列表
        $routeCollector->get('/adminapi/setting/menus/create','/adminapi/setting/systemmenus/create');//权限菜单表单	
        $routeCollector->post('/adminapi/setting/menus','/adminapi/setting/systemmenus/save');//添加权限菜单
        $routeCollector->put('/adminapi/setting/menus/{id}','/adminapi/setting/systemmenus/update');//修改权限菜单
        $routeCollector->get('/adminapi/setting/menus/{id}','/adminapi/setting/systemmenus/read');//读取权限菜单
        $routeCollector->delete('/adminapi/setting/menus/{id}','/adminapi/setting/systemmenus/delete');//删除权限菜单
        $routeCollector->put('/adminapi/setting/menus/show/{id}','/adminapi/setting/systemmenus/show');//显示权限菜单
	//role
        $routeCollector->get('/adminapi/setting/role','/adminapi/setting/SystemRole/index');//身份列表
        $routeCollector->get('/adminapi/setting/role/create','/adminapi/setting/SystemRole/create');//创建身份表单
        $routeCollector->get('/adminapi/setting/role/{id}/edit','/adminapi/setting/SystemRole/edit');//编辑身份表单
        $routeCollector->post('/adminapi/setting/role/{id}','/adminapi/setting/SystemRole/save');//保存新建或编辑身份
        $routeCollector->delete('/adminapi/setting/role/{id}','/adminapi/setting/SystemRole/delete');//删除身份
        $routeCollector->put('/adminapi/setting/role/set_status/{id}/{status}','/adminapi/setting/SystemRole/set_status');//修改身份状态
	
	//test
        $routeCollector->get('/product/list','/adminapi/login/login3');
        $routeCollector->get('/login2/{id:\d+}/a/{status}','/adminapi/login/login2');
	
	
        /*
         * eg path : /closure/index.html  ; /closure/ ;  /closure
         */
        $routeCollector->get('/closure',function (Request $request,Response $response){
            $response->write('this is closure router');
            //不再进入控制器解析
            return false;
        });
    }
}